var ${table.entityPath}Form_page={};
// 动作
${table.entityPath}Form_page.action = {
    initBody:function () {
        ${table.entityPath}Form_page.interface.initForm();
        ${table.entityPath}Form_page.action.bindEvent();
    },
    bindEvent:function () {
        layui.use(['form'],function () {
            var form = layui.form;
            form.on('submit(saveBtn)', function (data) {
                ${table.entityPath}Form_page.action.saveBtnClick();
                return false;
            });
        });
        $("#cancelBtn").click(function () {
            AppComm.utils.iframeCloseSelf();
            return false;
        });
    },
    // 在做action动作时校验数据data
    checkData:function (action, data) {
        var result = AppComm.data.newResult();
        if (action=='addSubmit') {
<#--        例子-->
<#--        if(data.parentId==""||data.parentId==null||data.parentId.trim()==""){-->
<#--            result.code = Enums.ResultEnum().FAILURE.code;-->
<#--            result.msg = "上级组织不能为空。";-->
<#--            return result;-->
<#--        }-->
        }
        return result;
    },
    saveBtnClick:function () {
        var params = {
        <#list cfg.tableFieldList as tableField>
            ${tableField.propertyName}:$("#${tableField.propertyName}").val(),
        </#list>
        };
        var checkResult = ${table.entityPath}Form_page.action.checkData(${table.entityPath}Form_page.data.action, params);
        if (checkResult.code==Enums.ResultEnum().FAILURE.code) {
            AppComm.layer.warm(checkResult.msg);
        } else {
            AppComm.ajax.post('/${table.entityPath}/ajax/save', params, function(resultData){
                AppComm.utils.iframeCloseSelf();
                parent.${table.entityPath}_page.interface.initTablePage();
                parent.AppComm.ajax.onSuccess(resultData);
            });
        }
    },
};

// 界面
${table.entityPath}Form_page.interface = {
    initForm:function () {
        if (${table.entityPath}Form_page.data.rowId == undefined || '' == ${table.entityPath}Form_page.data.rowId.trim()) {
            // 添加
            var html = template("${table.entityPath}Form_template");
            $(".${table.entityPath}Form_box").html(html);
        } else {
            // 编辑
            var params = {
                id: ${table.entityPath}Form_page.data.rowId
            };
            AppComm.ajax.get(${table.entityPath}Form_page.data.preAjax+'/getById', params, function(resultData){
                var html = template("${table.entityPath}Form_template", resultData.data);
                $(".${table.entityPath}Form_box").html(html);
                ${table.entityPath}Form_page.action.bindEvent();
            });
        }
    },
};
// 数据
${table.entityPath}Form_page.data = {
    'rowId':undefined,
    'preAjax':'/${table.entityPath}/ajax',
    'preForm':'/${table.entityPath}/form',
    'action':""
};